package yw.substart.example.svn;

import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.wc.ISVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

import java.io.File;

/**
 * @author lwq
 * @date 2018/5/17
 * @comment
 */
public class GetCode {

    private final String svn_url = "https://192.168.0.251/svn/his/";
    private final String username = "";
    private final String password = "";

    public void checkout() throws SVNException {
        //1.根据访问协议初始化工厂
        DAVRepositoryFactory.setup();
        //2.使用默认选项
        ISVNOptions isvnOptions = SVNWCUtil.createDefaultOptions(true);
        //3.初始化权限
        String username = "liwenqiang";
        String password = "liwenqiang";
        char[] pwd = password.toCharArray();
        ISVNAuthenticationManager isvnAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(username, pwd);
        //4.创建SVNClientManager的实例
        SVNClientManager svnClientManager = SVNClientManager.newInstance(isvnOptions, isvnAuthenticationManager);
        long nowRevision = svnClientManager.getUpdateClient()
                .doCheckout(SVNURL.parseURIEncoded("https://192.168.0.251/svn/his/"),
                        new File("E:\\svnWorkspace"), SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, true);
        System.out.println("执行checkout操作成功，当前检出的版本号是：" + nowRevision);
    }

    public static void main(String[] args) {



    }

}
